package com.groupbuying.task.controller;

import com.groupbuying.task.domain.XxlJobInfoDO;
import com.groupbuying.task.service.XxlJobInfoService;
import com.groupbuying.task.utils.apiresult.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author YinJie
 * @email 15048196013@163.com
 * @date 2019-11-29 09:41:29
 */

@RestController
@RequestMapping("/xxlJobInfo")
public class XxlJobInfoController {

    @Autowired
    private XxlJobInfoService xxlJobInfoService;

    /**
     * @api {post} /customer/getCustomerInfo 获取用户信息
     * @apiExample author  yinjie
     * tar 定时任务增加
     * date 2019/12/12 16:01
     * @apiGroup CustomerProducer
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} null 无
     * @apiSuccess {Integer} code 请求结果 0-失败 1-成功
     */

    @PostMapping("/add")
    public ApiResult increase(@RequestBody XxlJobInfoDO xxlJobInfoDO) {
        return xxlJobInfoService.add(xxlJobInfoDO);
    }

    /**
     * @api {post} /customer/getCustomerInfo 获取用户信息
     * @apiExample author  yinjie
     * tar 定时任务修改
     * date 2019/12/12 16:01
     * @apiGroup CustomerProducer
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} null 无
     * @apiSuccess {Integer} code 请求结果 0-失败 1-成功
     */
    @PostMapping("/update")
    public ApiResult update(@RequestBody XxlJobInfoDO xxlJobInfo) {
        return xxlJobInfoService.update(xxlJobInfo);
    }

    /**
     * @api {post} /customer/getCustomerInfo 获取用户信息
     * @apiExample author  yinjie
     * tar 用于红包定时任务修改
     * date 2019/12/18 16:09
     * @apiGroup CustomerProducer
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} null 无
     * @apiSuccess {Integer} code 请求结果 0-失败 1-成功
     */
    @PostMapping("/updateByExecutorParam")
    public ApiResult updateByExecutorParam(@RequestBody XxlJobInfoDO xxlJobInfo) {
        return xxlJobInfoService.updateByExecutorParam(xxlJobInfo);
    }

    /**
     * @api {post} /customer/getCustomerInfo 获取用户信息
     * @apiExample author  yinjie
     * tar 定时任务删除
     * date 2019/12/12 16:01
     * @apiGroup CustomerProducer
     * @apiVersion 1.0.0
     * @apiHeader {String} Authorization 用户授权token
     * @apiParam {String} null 无
     * @apiSuccess {Integer} code 请求结果 0-失败 1-成功
     */
    @GetMapping("/remove")
    public ApiResult remove(@RequestParam("id") Integer id) {
        return xxlJobInfoService.remove(id);
    }
}
